import {
  Entity,
  Column,
  UpdateDateColumn,
  CreateDateColumn,
  PrimaryGeneratedColumn,
  ManyToOne,
} from 'typeorm'
import { Department } from '../department/department.mysql.entity'

export enum UserStatus {
  disabled = 0,
  enabled = 1,
}

@Entity()
export class User {
  @PrimaryGeneratedColumn() // 自增主键
  id?: number

  @Column({ default: null })
  name: string

  @Column({ default: null })
  username: string

  @Column({ default: null })
  password: string

  @Column({ default: null })
  email: string

  @Column({ default: null })
  avatar?: string

  @Column({ default: null })
  mobile?: string

  @Column({ default: null })
  enName?: string

  @ManyToOne(() => Department, (department) => department.users)
  department: Department

  @Column({ default: null })
  departmentName?: string

  @Column({ default: null })
  departmentId?: number

  @Column({ default: UserStatus.enabled })
  status?: UserStatus

  @CreateDateColumn()
  createTime?: string

  @UpdateDateColumn()
  updateTime?: string
}
